package com.neusoft.ysu.populationmanagement.controller;

import com.neusoft.ysu.populationmanagement.entity.CommonResult;
import com.neusoft.ysu.populationmanagement.entity.LiveCard;
import com.neusoft.ysu.populationmanagement.service.ILiveCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2024-06-24
 */
@RestController
@RequestMapping("/live-card")
@CrossOrigin
public class LiveCardController {
    @Autowired
    ILiveCardService liveCardService;

    /**
     * @param idnum
     * @return com.neusoft.ysu.populationmanagement.entity.CommonResult
     * @author 赵子鉴
     * @描述 居住证制证
     * @date 2024-06-24 09:19
     */
    @RequestMapping("/apllyLiveCard")
    public CommonResult apllyLiveCard(String idnum,Long pid,Long operatorId) {
        return liveCardService.apllyLiveCard(idnum,pid,operatorId);
    }

    @RequestMapping("/buildLiveCard")
    public CommonResult buildLiveCard(String idnum,Long pid,Long operatorId) {
        return liveCardService.buildLiveCard(idnum,pid,operatorId);
    }

    @RequestMapping("/finishLiveCard")
    public CommonResult finishLiveCard(String idnum,Long pid,Long operatorId) {
        return liveCardService.finishLiveCard(idnum,pid,operatorId);
    }

    @RequestMapping("/sendLiveCard")
    public CommonResult sendLiveCard(String idnum,Long pid,Long operatorId) {
        return liveCardService.sendLiveCard(idnum,pid,operatorId);
    }

    @RequestMapping("/lossLiveCard")
    public CommonResult lossLiveCard(String idnum,Long pid,Long operatorId) {
        return liveCardService.lossLiveCard(idnum,pid,operatorId);
    }

    @RequestMapping("/deleteLiveCard")
    public CommonResult deleteLiveCard(String idnum,Long pid,Long operatorId) {
        return liveCardService.deleteLiveCard(idnum,pid,operatorId);
    }

    @RequestMapping("/selectLiveCardByIdnum")
    public CommonResult selectLiveCardByIdnum(String idnum) {
        List<LiveCard> list = liveCardService.selectLiveCardByIdnum(idnum);
        if (list.isEmpty()) {
            return new CommonResult<>(0, "未查到对应居住证", list);
        } else {
            return new CommonResult<>(1, "查询成功",list );
        }
    }
}
